package org.goyo.main.domain.entity.storage;

import java.io.Serializable;
import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import org.goyo.main.domain.entity.BaseEntryObject;
import org.goyo.main.domain.entity.base.BaseUnitMeasure;
import org.goyo.main.domain.entity.base.Material;
import org.goyo.main.domain.entity.base.MaterialEntry;
import org.goyo.main.domain.entity.base.Warehouse;
import org.goyo.main.domain.entity.pur.PurOrderEntry;
/**
 * 采购入库分录
 * 
 * @author chenchuan
 * 2014年11月12日
 */
@Entity
public class PurInStorageEntry extends BaseEntryObject implements Serializable {

	private static final long serialVersionUID = 1L;
	
//	/**
//	 * 采购订单
//	 */
//	@ManyToOne
//	@JoinColumn(name="purOrderId")
//	private PurOrder purOrder;
	
	/**
	 * 采购订单
	 */
	@ManyToOne
	@JoinColumn(name="purOrderEntryId")
	private PurOrderEntry purOrderEntry;
	
	/**
	 * 商品编码	
	 */
	@ManyToOne
	@JoinColumn(name="materialId")
	private Material material;
	/**
	 * 商品名称	
	 */
	@Column
	private String materialName;
	/**
	 * 商品规格型号	
	 */
	@Column
	private String materialStandard;
	/**
	 * 基本计量单位	
	 */
	@ManyToOne
	@JoinColumn(name="jilUnitId")
	private BaseUnitMeasure jilUnit;
	/**
	 * 辅助计量单位	
	 */
	@ManyToOne
	@JoinColumn(name="fjilUnitId")
	private MaterialEntry fjilUnit;
	/**
	 * 批次	
	 */
	@Column
	private String lot;
	/**
	 * 条码	
	 */
	@Column
	private String barCode;
	/**
	 * 保质到期日	
	 */
	@Column
	private String expiraDate;
	/**
	 * 基本数量	
	 */
	@Column
	private double inStorageQty = 0;
	
	   /**
     * 辅助换算率
     */
    @Column
    private String conversionRate;
	
	/**
	 * 辅助数量	
	 */
	@Column
	private double finStorageQty = 0;
	/**
	 * 仓库	
	 */
	@ManyToOne
	@JoinColumn(name="warehouseId")
	private Warehouse warehouse;
	/**
	 * 入库单位成本	
	 */
	@Column
	private BigDecimal inStorageUtilCost = BigDecimal.ZERO;
	/**
	 * 入库成本	
	 */
	@Column
	private BigDecimal inStorageCost = BigDecimal.ZERO;
	/**
	 * 累计退库数量	
	 */
	@Column
	private double sumQuitQty = 0;
	public String getMaterialName() {
		return materialName;
	}
	public void setMaterialName(String materialName) {
		this.materialName = materialName;
	}
	public String getMaterialStandard() {
		return materialStandard;
	}
	public void setMaterialStandard(String materialStandard) {
		this.materialStandard = materialStandard;
	}
	
	public BaseUnitMeasure getJilUnit() {
		return jilUnit;
	}
	public void setJilUnit(BaseUnitMeasure jilUnit) {
		if(jilUnit != null &&("".equals(jilUnit.getUuid()) || jilUnit.getUuid()==null))
			this.jilUnit = null;
		else
			this.jilUnit = jilUnit;	
	}
	public String getLot() {
		return lot;
	}
	public void setLot(String lot) {
		this.lot = lot;
	}
	public String getBarCode() {
		return barCode;
	}
	public void setBarCode(String barCode) {
		this.barCode = barCode;
	}
	public String getExpiraDate() {
		return expiraDate;
	}
	public void setExpiraDate(String expiraDate) {
		this.expiraDate = expiraDate;
	}

	public Material getMaterial() {
		return material;
	}
	public void setMaterial(Material material) {
		if(material != null &&("".equals(material.getUuid()) || material.getUuid()==null))
			this.material = null;
		else
			this.material = material;	
	}
	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	
	public PurOrderEntry getPurOrderEntry() {
		return purOrderEntry;
	}
	public void setPurOrderEntry(PurOrderEntry purOrderEntry) {
		if(purOrderEntry != null &&("".equals(purOrderEntry.getUuid()) || purOrderEntry.getUuid()==null))
			this.purOrderEntry = null;
		else
			this.purOrderEntry = purOrderEntry;
	}
	public Warehouse getWarehouse() {
		return warehouse;
	}
	
	public void setWarehouse(Warehouse warehouse) {
		if(warehouse != null &&("".equals(warehouse.getUuid()) || warehouse.getUuid()==null))
			this.warehouse = null;
		else
			this.warehouse = warehouse;	
	}
/*	public BaseUnitMeasure getFjilUnit() {
		return fjilUnit;
	}
	public void setFjilUnit(BaseUnitMeasure fjilUnit) {
		this.fjilUnit = fjilUnit;
	}*/
	public double getInStorageQty() {
		return inStorageQty;
	}
	public MaterialEntry getFjilUnit() {
    return fjilUnit;
  }
  public void setFjilUnit(MaterialEntry fjilUnit) {
    if(fjilUnit != null &&("".equals(fjilUnit.getUuid()) || fjilUnit.getUuid()==null))
      this.fjilUnit = null;
  else
      this.fjilUnit = fjilUnit; 
  }
  public String getConversionRate() {
    return conversionRate;
  }
  public void setConversionRate(String conversionRate) {
    this.conversionRate = conversionRate;
  }
  public void setInStorageQty(double inStorageQty) {
		this.inStorageQty = inStorageQty;
	}
	public double getFinStorageQty() {
		return finStorageQty;
	}
	public void setFinStorageQty(double finStorageQty) {
		this.finStorageQty = finStorageQty;
	}
	public BigDecimal getInStorageUtilCost() {
		return inStorageUtilCost;
	}
	public void setInStorageUtilCost(BigDecimal inStorageUtilCost) {
		this.inStorageUtilCost = inStorageUtilCost;
	}
	public BigDecimal getInStorageCost() {
		return inStorageCost;
	}
	public void setInStorageCost(BigDecimal inStorageCost) {
		this.inStorageCost = inStorageCost;
	}
	public double getSumQuitQty() {
		return sumQuitQty;
	}
	public void setSumQuitQty(double sumQuitQty) {
		this.sumQuitQty = sumQuitQty;
	}
	
	
}
